# include <bits/stdc++.h>
using namespace std;
int main() { 
    int h, m;
    char ch;
    cin >> h >> ch >> m;
    int ans = 0;
    while(((h / 10) != (m % 10)) || ((m / 10) != (h % 10))) {
        ans++;
        m++;
        if(m == 60) {
            h++;
            m = 0;
        }
        if(h == 24) {
            h = 0;
        }
    }
    cout << ans << endl;
    return 0;
}